package com.boesch.electroOffice.utils;

import java.util.ArrayList;
import java.util.List;

import javax.portlet.PortletRequest;

import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;

public class UserUtils {

	public static User getCurrentUser() {
		PortletRequest request = PortletUtils.getPortletRequest();
		ThemeDisplay display = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
		User currentUser = display.getRealUser();
		return currentUser;
	}

	public static List<User> getAllUsers() throws SystemException {
		List<User> users = UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
		return users;
	}

	public static List<User> getAllBoeschUsers() throws SystemException {
		List<User> users = UserLocalServiceUtil.getGroupUsers(LiferayUtils.getCurrentGroupId());
		List<User> boeschUsers = new ArrayList<User>();
		for (User user : users) {
			if (10198 != user.getUserId()) {
				boeschUsers.add(user);
			}
		}
		return boeschUsers;
	}
}
